#include<iostream>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<string.h>
using namespace std;

int main()
{   
    int fd=open("test.txt",O_CREAT|O_WRONLY,0666);
    int fdd=open("test.txt",O_CREAT|O_RDONLY);
    int fddd=open("test.txt",O_CREAT|O_WRONLY,0666);
    char str[]="hello fd\n";
    write(3,str,9);
    cout<<fd<<endl;
    cout<<fdd<<endl;
    cout<<fddd<<endl;

    return 0;
}